$(document).ready(function() {
    var heightWin = $(window).height();
    var turnPlay = 4;
    var stars = ["star1", "star2", "star3"];
    var flags = ["flag1", "flag2", "flag3", "flag4"];
    var status = ["true", "true", "true", "true"];   
    if (heightWin < 640) {
        heightWin = 640;
    }
    $("#content .game_area").parent().children().children("img").attr("mute","false");
    var sound = new Audio("sound/gpmn.mp3");
    sound.loop = true;
    sound.play();
    //$("#page_wapper").css("min-height", heightWin);
    //$("#main_content").css("min-height", heightWin - 53);
    $("#content .game_area img").click(function(){
		if(jQuery(this).attr("mute") == null || jQuery(this).attr("mute") == "false" || 
		jQuery(this).attr("mute") == undefined)
		{
            sound.muted = true;
    		$(this).attr("mute","true");
    		$(this).attr("src","images/sound_mute.png");
		}
		else
		{
            sound.muted = false;
			jQuery(this).attr("mute","false");
			jQuery(this).attr("src","images/sound_play.png");
		}
	});
    $("#content .infor img.sound").click(function(){
		if(jQuery(this).attr("mute") == null || jQuery(this).attr("mute") == "false" || 
		jQuery(this).attr("mute") == undefined)
		{
            sound.muted = true;
    		$(this).attr("mute","true");
    		$(this).attr("src","images/sound_mute.png");
		}
		else
		{
            sound.muted = false;
			jQuery(this).attr("mute","false");
			jQuery(this).attr("src","images/sound_play.png");
		}
	});
    /*$("#content .game_area span.star").click(function(e){
        if (turnPlay != 0) {
            var phaohoa = new Audio("sound/phaohoa.mp3");
            for (var i = 0; i < stars.length; i++) {
                if (e.target.id == stars[i]) {
                    phaohoa.play();
                    $("#content .game_area span#firework" + (i + 1)).css("display", "block");
                    showScore(e);
                    turnPlay--;
                }
            }
        } else {
            var ohoh = new Audio("sound/OhOh.mp3");
            ohoh.play();
            showTurnOff(e);
        }
        
    });
    $("#content .game_area span.flag").click(function(e){
        if (turnPlay != 0) {
        for (var i = 0; i < flags.length; i++) {
                if (e.target.id == flags[i] && status[i] == "true") {
                var phaohoa = new Audio("sound/FlagSounds.mp3");
                phaohoa.play();
                $("#content .game_area span#flag" + (i + 1)).css({"background": "url('images/flag.png') no-repeat",
                                                                    "background-size": "contain"
                                                                    });
                showScore(e);
                status[i] = "false";
                turnPlay--;
                }
        }
        
        // -1 : het. 10-60, 100 = x2, 50000 
        } else {
            var ohoh = new Audio("sound/OhOh.mp3");
            ohoh.play();
            showTurnOff(e);
        }
    });*/
});
/*function showTurnOff(e) {
    $(".scoreplus").css({
            "top": e.pageY - 50,
            "left": e.pageX - 50,
            "background": "url('images/turnoff.png') no-repeat",
            "background-size": "contain",
            "display": "block"
        });
    $(".scoreplus").animate({top: (e.pageY - 100) + 'px'},"slow");
    $(".scoreplus").fadeOut(200);
}
function showScore(e) {
    $(".scoreplus").css({
            "top": e.pageY - 50,
            "left": e.pageX - 50,
            "background": "url('images/" + data +".png') no-repeat",
            "background-size": "contain",
            "display": "block"
        });
    $(".scoreplus").animate({top: (e.pageY - 100) + 'px'},"slow");
    $(".scoreplus").fadeOut(500);
}*/
function showMore() {
    $("#footer .rule_topten .contain .rule_left").css("overflow-y", "scroll");
    $("#footer .rule_topten .contain .rule_left a#showmore").hide();
    $("#footer .rule_topten .contain .rule_left a#hideInfor").show();
    $("#footer .rule_topten .contain .rule_left p.hidden_infor").show();
}
function hideInfor() {
    $("#footer .rule_topten .contain .rule_left").css("overflow-y", "none");
    $("#footer .rule_topten .contain .rule_left a#showmore").show();
    $("#footer .rule_topten .contain .rule_left a#hideInfor").hide();
    $("#footer .rule_topten .contain .rule_left p.hidden_infor").hide();
}
function showMoreIntro() {
    $("#content .infor .right_infor .details .rule a#showmore").hide();
    $("#content .infor .right_infor .details .rule a#hideInfor").show();
    $("#content .infor .right_infor .details .rule p.hidden_infor").show();
}
function hideInforIntro() {
    $("#content .infor .right_infor .details .rule a#showmore").show();
    $("#content .infor .right_infor .details .rule a#hideInfor").hide();
    $("#content .infor .right_infor .details .rule p.hidden_infor").hide();
}